package com.szqhyxj.youxiangju.sys.components

import android.app.Activity
import android.app.AlertDialog

class YesOrNo {

    companion object {
        fun createDialog(activity: Activity, title: String, message: String, noMessage: String, yesMessage: String, noListener: NoListener, yesListener: YesListener): AlertDialog {
            return AlertDialog.Builder(activity).apply {
                this.setTitle(title)
                this.setMessage(message)
                this.setPositiveButton(yesMessage) { _, _ -> yesListener.yes() }
                this.setNegativeButton(noMessage) { _, _ -> noListener.no() }
            }.create()
        }
    }
}

interface YesListener {
    fun yes()
}

interface NoListener {
    fun no()
}